package likong.bibliothek.pages.buch;

import likong.bibliothek.obj.Buch;

import org.apache.wicket.PageParameters;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;


import db.HibernateHelper;

public class BuecherNeu extends BuchAbstract{
	public BuecherNeu(){
		Buch buch = new Buch();
		final CompoundPropertyModel<Buch> model = new CompoundPropertyModel<Buch>(buch);
		
		// Panel einfügen
		add(new BuecherFormPanel("neuesBuchFormular", model) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmitModelHandle(IModel<Buch> model) {
				Integer id = (Integer) HibernateHelper.save(model.getObject());
				
				PageParameters params = new PageParameters();
				params.add("buchID", id.toString());
				
				this.setRedirect(true);
				this.setResponsePage(BuecherWeb.class);
			}
		});
	}

}
